#!/usr/bin/python

import sys
import cgi
import pg


import cgitb

cgitb.enable()

def stdprintf(string=""):
        sys.stdout.write(string)
        sys.stdout.write('\n\n')
        sys.stdout.flush()

header = 'Content-Type: text/html'
form = cgi.FieldStorage()
#action = form['action'].value
owner_id = form['owner'].value

password = ''
username = 'plesk'
db_name = 'plesk'




select_st = "SELECT st_id, name from service_templates where owner_id = %s" % owner_id


db = pg.connect(dbname = db_name, host =  hostname, user = username)

str = ""
for i in db.query(select_st).dictresult():
        str += "<input type = 'checkbox' name = 'service_templates' value = %(st_id)s checked> %(name)s <br>" % i



db.close()

stdprintf(header)
stdprintf("<html><head><title>QA TOOLS</title></head><body>")
stdprintf("<form action = 'backup.py' method = get>")

stdprintf(str)
#stdprintf("<input type = 'hidden' name = 'action' value = %s >" % action)
stdprintf("<input type='submit' value='>>Next>>'>")
stdprintf("</body></html>")


